import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:fate_blind_box/model/member_list_entity.dart';
import 'package:fate_blind_box/network/ApiService.dart';
import 'package:fate_blind_box/network/http_config.dart';
import 'package:fate_blind_box/network/http_request.dart';
import 'package:fate_blind_box/utils/provider.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:universal_html/html.dart' as html;

class Api {
  Api._();

  static Api? _instance;

  static Api getInstance() {
    return _instance ??= Api._();
  }

  final _service = ApiService();

  Future? login(String code) {
    return HttpRequest.request(_service.login, params: {"code": "0000"});
  }

  Future? getMatchmakerList(int pageSize, int pageNo) {
    return HttpRequest.request(_service.matchmakerList,
        params: {"pageNum": pageNo, "pageSize": pageSize});
  }

  Future? publishFateLine(
      int minNum, int maxNum, String startTime, String endTime) {
    return HttpRequest.request(_service.publishFateLine, params: {
      "minimum": minNum,
      "maximum": maxNum,
      "startTime": startTime,
      "endTime": endTime
    });
  }

  /// 获取好友圈列表
  Future? getMoodList(String memberId, int pageNum, int pageSize) {
    return HttpRequest.request(_service.mood, method: "get", params: {
      "memberId": memberId,
      "pageNum": pageNum,
      "pageSize": pageSize
    });
  }

  /// 获取好友列表
  Future? getFriendList(String memberId) {
    return HttpRequest.request(_service.friendLists, method: "post", params: {
      // "easeuserId": memberId,
      "easename": memberId,
    });
  }

  /// 群拉人进好友列表
  Future? getFriendGroupList(String groupId, String username) {
    return HttpRequest.request(_service.friendGroupLists,
        method: "post", params: {"groupId": groupId, "username": username});
  }

  /// 获取群组列表（加缓存）
  Future? getGroupList(String memberId) {
    return HttpRequest.request(_service.groupLists, method: "post", params: {
      "username": memberId,
    });
  }

  /// 获取群组列表缓存
  Future? groupListsCache(String username) {
    return HttpRequest.request(_service.groupListsCache,
        method: "post",
        params: {
          "username": username,
        });
  }

  /// 获取粉丝列表
  Future? getFanLists(String easename) {
    return HttpRequest.request(_service.fanLists, method: "post", params: {
      "easename": easename,
    });
  }

  /// 删除好友
  Future? deleteUsers(String memberId) {
    return HttpRequest.request(_service.removeDetails, method: "post", params: {
      "contactId": memberId,
    });
  }

  /// 获取群组成员
  Future? getGroupMembers(String memberId, String owner) {
    return HttpRequest.request(_service.groupMembers, method: "post", params: {
      "groupId": memberId,
      "owner": owner,
    });
  }

  /// 获取所有群组成员
  Future? getGroupAllMembers(String memberId, String username) {
    return HttpRequest.request(_service.groupAllMembers,
        method: "post",
        params: {
          "groupId": memberId,
          "username": username,
        });
  }

  Future? getGroupInformation(String groupId, String username) {
    return HttpRequest.request(_service.groupInformation,
        method: "post",
        params: {
          "groupId": groupId,
          "username": username,
        });
  }

  /// 获取红娘圈列表
  Future? getMatchmakerMoods(int pageNum) {
    return HttpRequest.request(_service.matchMakerMoods,
        method: "get", params: {"pageNum": pageNum, "pageSize": 20});
  }

  /// 发布好友圈
  Future? publishMood(String memberId, String content, String picUrls,
      int visit, List<String> visitList) {
    return HttpRequest.request(_service.mood, params: {
      "content": content,
      "memberId": memberId,
      "picUrls": picUrls,
      "visit": 0,
      "visitList": visitList
    });
  }

  /// 获取盲盒剩余次数
  Future? getBlindBoxRemainCount() {
    return HttpRequest.request(_service.blindBoxRemainCount, method: "get");
  }

  /// 打开盲盒获取信息
  Future? openBlindBox() {
    return HttpRequest.request(_service.blindBoxInfo, method: "get");
  }

  /// 盲盒打招呼
  Future? hiBlindBox(String hi, String openId) {
    return HttpRequest.request(_service.blindBoxHi,
        params: {"msg": hi, "targetOpenId": openId});
  }

  /// 分页获取圈子评论列表
  Future? getMoodComments(
      String memberId, String moodId, int pageNum, int pageSize) {
    return HttpRequest.request(_service.moodCommentList,
        method: "GET",
        params: {
          "memberId": memberId,
          "moodId": moodId,
          "pageNum": pageNum,
          "pageSize": pageSize
        });
  }

  /// 评论圈子
  Future? commentMood(
    String commendId, // 上级评论id,直接评论动态时传0
    String content,
    String memberId,
    String moodId,
  ) {
    return HttpRequest.request(_service.moodComment, params: {
      "parentId": commendId,
      "content": content,
      "memberId": memberId,
      "moodId": moodId
    });
  }

  Future? moodThumb(
    String commentId, // 评论id,动态点赞或取消传0
    String memberId,
    String moodId,
    int flag, // 1-点赞，0-取消点赞
  ) {
    return HttpRequest.request(_service.moodThumb, params: {
      "commentId": commentId,
      "memberId": memberId,
      "moodId": moodId,
      "flag": flag
    });
  }

  /// 查看是否又月老牵线活动
  Future? hasFateLine() {
    return HttpRequest.request(_service.hasFateLine, params: {});
  }

  /// 月老牵线-会员列表
  Future? fateLineMembers(String memberId, int pageSize, int pageNum) {
    return HttpRequest.request(_service.fateLineMembers, params: {
      "id": memberId,
      "pageSize": pageSize,
      "pageNum": pageNum,
    });
  }

  /// 相亲活动-列表
  Future? blindActives(
      String timeType, String activName, int pageNum, int pageNo) {
    return HttpRequest.request(_service.blindActives, params: {
      "timeType": timeType, //--时间类型,TODAY:今日活动;TOMORROW:未来热门;PAST:往期精彩
      "activName": activName, //-- 活动名称
      "pageNum": pageNum, //-- 当前页
      "pageSize": pageNo //-- 当前页码
    });
  }

  /// 相亲活动存稿、发布
  /// 请求参数说明
  //   1. 通过字段`activStatus` 值来区分是存稿，还是直接 发布 activStatus=0:存稿;1:发布
  //   2. 字段`freeType` 收费类型，统一收费、按性别收费
  //      freeType = 1, 统一收费，对应的相关字段值
  //        nonMemberFee,memberFee,fee,freeHours
  //      freeType = 2, 按性别收费，对应的相关字段值
  //        manNonMemberFee、manMemberFee、manFee、manFeeHours、womanNonMemberFee、womanMemberFee、womanFee、womanFeeHours
  //   3.字段`focusImg` 焦点图
  ///
  /// {
  // 	"id":"2b497e3203fd4ab2bff0da2368220b2c",    -- 活动ID,如果有存稿,从接口5 中取出来
  // 	"activName":"圣诞节2",                       -- 活动名称
  // 	"activStatus":1,                            -- 点击存稿 传0，发布 传1
  // 	"contactUser":"康师傅1",                     -- 活动联系人
  // 	"contactPhone": "18611623912",              -- 活动联系电话
  // 	"focusImg":"/profile/upload/161de5a2b5c8968f6.png",   -- 活动焦点图
  // 	"startDate":"2019-12-01 10:00:00",          -- 开始时间
  // 	"endDate":"2019-12-30 10:00:00",            -- 结束时间
  // 	"freeType":1,                               -- 收费类型,:1:统一收费,2:区分性别收费
  // 	"nonMemberFee":13.3,                     --统一收费 -活动报名费
  // 	"memberFee":12.3,                        -- 统一收费 - 会员报名费
  // 	"fee":8.3,                               -- 统一收费 - 空投费
  // 	"freeHours":1,                           -- 统一收费 - 活动前几个小时收取空降费
  //   "manNonMemberFee":13.3,                  --男-活动报名费
  // 	"manMemberFee":12.3,                     -- 男-会员报名费
  // 	"manFee":8.3,                            -- 男-空投费
  // 	"manFeeHours":1,                         -- 男-空投费 活动前几个小时收取空降费
  //   "womanNonMemberFee":13.3,                -- 女-活动报名费
  // 	"womanMemberFee":12.3,                   -- 女-会员报名费
  // 	"womanFee":8.3,                          -- 女-空投费
  // 	"womanFeeHours":1,                       -- 女-空投费 活动前几个小时收取空降费
  // 	"activContent":"测试eeeee",              --活动描述(内容)
  // 	"activAddr":"北京-五棵松",                --活动地址
  // 	"activAddrDetailed":"B1层",              -- 联系地址-详细地址
  // 	"refundType":1,       -- 活动退款类型,1:活动结束前均可退款;2:活动结束前x天可以退款;3:不支持退款
  // 	"refundDays":5,       -- 活动退款类型,(refundType=2):活动退款天数
  // 	"memberId":"16ddefd723b211ea8ceb00163e3216d3",   -- 会员ID
  //   "releaseMethod":1               --活动发布方式: 1:非公开发布;2:公开发布;
  // }
  Future? publishBlindActive(Map<String, dynamic> p) {
    return HttpRequest.request(_service.blindActivePublish, params: p);
  }

  /// 诚信约会-列表
  Future? getFaithDatingList(int type, int pageNum, int pageSize) {
    return HttpRequest.request(_service.faithDatingList,
        params: {"type": type, "pageNum": pageNum, "pageSize": pageSize});
  }

  /// 诚信约会-发布
  /// {
  //         "type":0,  //-- 约会主题类型  0-吃饭;
  //         "inviteMethod":0,  //--邀约方法: 0-邀请人付费
  //         "creditAmount":0.01,  //--信用金
  //         "startTime":"2020-06-15 11:00:00",
  //         "endTime":"2020-06-15 14:00:00",
  //         "location":"北京",  //--约会地点
  //         "content":"约会内容"
  //       }
  Future? publishFaithDating(Map<String, dynamic> p) {
    return HttpRequest.request(_service.faithDatingRelease, params: p);
  }

  /// 诚信约会-详情
  Future? getFaithDatingInfo(int type, String id) {
    return HttpRequest.request(_service.fatihDatingInfo, params: {
      "type": type, // --类型;  0-诚信约会;1-我的邀约;2-我的赴约
      "id": id
    });
  }

  /// 诚信约会-赴约
  Future? goFaithDating(String id) {
    return HttpRequest.request(_service.goFaithDating, params: {"id": id});
  }

  /// 获取用户信息
  Future? getMemberInfo(String id) {
    return HttpRequest.request(_service.getMemberById, params: {
      "id": id,
    });
  }

  /// 获取好友信息
  Future? getFriendInfo(String id) {
    return HttpRequest.request(_service.friendInformation, params: {
      "id": id,
    });
  }

  /// 获取环信用户信息
  Future? getUserInfo(String id) {
    return HttpRequest.request(_service.userDetails, params: {
      "username": id,
    });
  }

  /// 查询环信用户信息
  Future? queryUserInfo(String id) {
    return HttpRequest.request(_service.queryUsers, params: {
      "profileNo": id,
    });
  }

  /// 查询个人简介
  Future? queryUserIntroduce(String id) {
    return HttpRequest.request(_service.queryExtSig, params: {
      "memberId": id,
    });
  }

  ///修改个人简介
  Future? ModifyMeIntroduce(String id, String signature) {
    return HttpRequest.request(_service.modifyExtSig, params: {
      "memberId": id,
      "signature": signature,
    });
  }

  // Future? institution(String id,String signature) {
  //   return HttpRequest.request(
  //       _service.institution,
  //       params: {
  //         "name": id,
  //         "idCardNo": signature,
  //       }
  //   );
  // }

  Future? idcardIdentify(String idCardNo, String name, String memberId,
      String front, String back) {
    return HttpRequest.request(_service.idcardIdentify, params: {
      "idCardNo": idCardNo,
      "name": name,
      "memberId": memberId,
      "front": front,
      "back": back
    });
  }

  //营业执照核验
  Future? verifyLicense(
      String companyName, String creditCode, String businessAddress) {
    return HttpRequest.request(_service.verifyLicense, params: {
      "companyName": companyName,
      "creditCode": creditCode,
      "businessAddress": businessAddress
    });
  }

  ///修改昵称
  Future? ModifyNick(String id, String nickName) {
    return HttpRequest.request(_service.modifyNick,
        params: {"memberId": id, 'nickName': nickName});
  }

  /// 创建群
  Future? creatGroup(String owner, List list) {
    return HttpRequest.request(_service.creatGroup,
        params: {"owner": owner, "members": list});
  }

  /// 添加群成员
  Future? addGroupUsers(String groupId, List list) {
    return HttpRequest.request(_service.addGroupUsers,
        params: {"groupId": groupId, "members": list});
  }

  /// 查询群信息
  Future? queryGroupInfo(String id) {
    return HttpRequest.request(_service.queryGroup, params: {
      "nameORId": id,
    });
  }

  /// 添加环信用户信息
  Future? addUserInfo(String id) {
    return HttpRequest.request(_service.addUsers, params: {
      "contactId": id,
    });
  }

  /// 添加多个群成员信息
  Future? addGroup(List list, String groupId) {
    return HttpRequest.request(_service.addGroupUsers, params: {
      "groupId": groupId,
      "addGroupUsers": list,
    });
  }

  /// 添加单个群成员信息
  Future? addGroupMember(String name, String groupId) {
    return HttpRequest.request(_service.addGroup, params: {
      "groupId": groupId,
      "easemobId": name,
    });
  }

  /// 添加单个群成员信息
  Future? quitGroup(String groupId) {
    return HttpRequest.request(_service.quitGroup, params: {
      "groupId": groupId,
    });
  }

  /// 获取环信群组信息
  Future? getGroupInfo(String id) {
    return HttpRequest.request(_service.groupDetails, params: {
      "groupId": id,
    });
  }

  /// 修改群名称
  Future? upDataGroupInfo(String id, String groupName) {
    // print('--------------------'+{"groupId": groupId, "easemobId": name,}.toString());
    return HttpRequest.request(_service.upDataGroupDetails, params: {
      "groupId": id,
      "groupName": groupName,
    });
  }

  /// 之前注释-获取会话消息
  /// 新注释- 根据会话id 获取当前会话的还有资料
  Future? getSessions(String id) {
    return HttpRequest.request(_service.queryGroupORMember, params: {
      "detailsId": id,
    });
  }

  /// 修改会员资料
  Future? modifyProfile(Map<String, dynamic> p) {
    return HttpRequest.request(_service.modifyProfile, params: p);
  }

  /// 上传头像
  Future? uploadAvatar(String id, String path) {
    return HttpRequest.uploadFile(_service.uploadAvatar, params: {
      "avatarfile": MultipartFile.fromFileSync(path),
      "memberId": id
    });
  }

  /// 完善信息--绑定手机号
  Future? perfectInformationBindingPhoneNumber(String phoneNo, String smsCode,
      String smsSig, String password, String conPassword) {
    return HttpRequest.request(_service.perfectInformationBindingPhoneNumber,
        params: {
          "phoneNo": phoneNo,
          "smsCode": smsCode,
          "smsSig": smsSig,
          "password": password,
          "conPassword": conPassword
        });
  }

  /// 完善信息--头像/昵称/性别/生日
  Future? perfectInformationAvator(
      String id, String nickName, int realSex, String birthYear, String path) {
    return HttpRequest.request(_service.perfectInformationAvator, params: {
      "memberId": id,
      "nickName": nickName,
      "realSex": realSex,
      "birthYear": birthYear,
      "profilePhoto": path,
    });
  }

  /// 上传群头像
  Future? uploadAvatarOfGroup(String groudId, String path) {
    return HttpRequest.uploadFile(_service.uploadAvatarOfGroup, params: {
      "avatarfile": MultipartFile.fromFileSync(path),
      "groudId": groudId
    });
  }

  /// 网页上传头像
  uploadAvatarFromHtml(html.FormData data, Function callback) {
    final res = html.HttpRequest();
    res.open("POST",
        "${HttpConfig.baseUrl}${HttpConfig.webApi}/${_service.uploadAvatar}");
    res.setRequestHeader("Authorization", HttpConfig.token);
    res.send(data);
    res.onLoadEnd.listen((event) {
      callback(jsonDecode(res.response));
    });
  }

  /// 登录-发送验证码
  Future? loginSendCode(String mob) {
    return HttpRequest.request(_service.loginSendCode,
        params: {"phoneNo": mob});
  }

//注册
  Future? registerSend(
      String mob, String code, String sig, String pass, String conPass) {
    return HttpRequest.request(_service.registerBySms, params: {
      "phoneNo": mob,
      "smsCode": code,
      "smsSig": sig,
      "password": pass,
      "conPassword": conPass
    });
  }

  /// 登录-修改Miami
  Future? modfyPass(
      String phone, String code, String sig, String pass, String conPass) {
    return HttpRequest.request(_service.modfyPassBySms, params: {
      "phoneNo": phone,
      "smsCode": code,
      "smsSig": sig,
      "password": pass,
      "conPassword": conPass
    });
  }

  /// 校验验证码
  /// @params msgType 消息类型为“验身（AUTH）|注册（REG）|登录（LOGIN）|改密（PWD）|变更（CONF）”（不不可为空）
  Future? verifySms(String mob, String sms, String sign, String msgType) {
    return HttpRequest.request(_service.verifySms, params: {
      "phoneNo": mob,
      "msgType": msgType,
      "smsCode": sms,
      "smsSig": sign
    });
  }

  /// 验证码登录
  Future? loginBySms(String mob, String sms, String sign) {
    return HttpRequest.request(_service.loginBySms, params: {
      "phoneNo": mob,
      "smsCode": sms,
      "smsSig": sign,
    });
  }

  /// 密码登录
  Future? passloginBySms(String mob, String pass) {
    return HttpRequest.request(_service.passloginBySms, params: {
      "phoneNo": mob,
      'password': pass,
    });
  }

  /// 保存性别
  Future? saveRealSex(
    int realSex,
  ) {
    return HttpRequest.request(_service.saveRealSex, params: {
      "realSex": realSex,
    });
  }

  /// 完善跟人信息
  Future? completeUserInfo(
    String userId,
    String profilePhoto,
    String nickname,
    int gender,

    /// 0:未定，1:男，2:女，3:其他
    String birthYear,
    String shareCode,
    String loginSign,
  ) {
    return HttpRequest.request(_service.completeUserInfo, params: {
      "memberId": userId,
      "nickName": nickname,
      "realSex": gender,
      "birthYear": birthYear,
      "shareCode": shareCode,
      "profilePhoto": profilePhoto,
      "sig": loginSign,
    });
  }

  Future? getMatcherFans(
      String memberId, int pageNo, int pageSize, int realSex) {
    return HttpRequest.request(_service.matcherFans, params: {
      "memberId": memberId,
      "pageNum": pageNo,
      "pageSize": pageSize,
      "realSex": realSex
    });
  }

  Future? getAlbum() {
    return HttpRequest.request(_service.getAlbum, params: {});
  }

  Future? addAlbum(String name, String remarks) {
    return HttpRequest.request(_service.addAlbum,
        params: {"name": name, "remarks": remarks});
  }

  addPic2AlbumHtml(String photoId, List<html.File> photos, Function callback) {
    final formData = html.FormData();
    for (var file in photos) {
      formData.appendBlob("photos", file.slice(), file.name);
    }
    formData.append("photoId", photoId);
    HttpRequest.uploadFileFromHtml(_service.addPic2Album, formData, callback);
  }

  /// 上传身份证正反面
  Future? uploadCard(String frontPath, String backPath) {
    return HttpRequest.uploadFile(_service.uploadCard, params: {
      "front": MultipartFile.fromFileSync(frontPath),
      "back": MultipartFile.fromFileSync(backPath)
    });
  }

  /// 上传身份证正反面
  Future? uploadLicense(String license) {
    return HttpRequest.uploadFile(_service.uploadLicense, params: {
      "license": MultipartFile.fromFileSync(license),
    });
  }

  Future? addPic2Album(String photoId, List<String> photos) {
    return HttpRequest.uploadFile(_service.addPic2Album, params: {
      "photos": MultipartFile.fromFileSync(photos[0]),
      "photoId": photoId
    });
  }

  personalPhotos(html.File photo, Function callback) {
    final formData = html.FormData();
    formData.appendBlob("avatar", photo.slice(), photo.name);
    formData.append("isMain", "0");
    HttpRequest.uploadFileFromHtml(_service.personalPhotos, formData, callback);
  }

  Future? getWechatOpenId(String code) {
    return Dio().request("https://api.weixin.qq.com/sns/oauth2/access_token",
        data: "get",
        queryParameters: {
          "code": code,
          "appId": Provider.wechatAppID,
          "secret": Provider.wechatAppSecret,
          "grant_type": "authorization_code",
        });
  }

  Future? loginByWechat(String code) {
    return HttpRequest.request(_service.loginByWechat, params: {"code": code});
  }

  // 公众号微信登录
  Future? wechatLogin(String code) {
    return HttpRequest.request(_service.wechatLogin, params: {"code": code});
  }

  // 保存app消息列表到web
  Future? addMessagelist(String easename, List list, String genre) {
    return HttpRequest.request(_service.addEaasemob, params: {
      "easemobIds": list,
      "easename": easename,
      "genre": genre,
    });
  }

  // web获取app会话列表
  Future? getMessagelist(String easename, String genre) {
    return HttpRequest.request(_service.getEaasemob, params: {
      "memberId": easename,
      "genre": genre,
    });
  }

  // app注销
  Future? logoOut(String easename) {
    return HttpRequest.request(_service.userLogout, params: {
      "memberId": easename,
    });
  }

  // app注册
  Future? appRegister(String phoneNo, String smsCode, String smsSig,
      String password, String conPassword) {
    return HttpRequest.request(_service.appRegister, params: {
      "phoneNo": phoneNo,
      "smsCode": smsCode,
      "smsSig": smsSig,
      "password": password,
      "conPassword": conPassword,
    });
  }

  // 环信注册
  Future? ImRegister(String code) {
    return HttpRequest.request(_service.registerEasemob,
        params: {"code": code});
  }

  // 环信登录
  Future? ImLogin(String id) {
    return HttpRequest.request(_service.loginEasemob, params: {"memberId": id});
  }

  // app微信登录
  Future? wechatLoginApp(String code) {
    return HttpRequest.request(_service.wechatAppLogin, params: {"code": code});
  }

  // 修改择偶信息
  Future? modifyMcs(Map<String, dynamic> p) {
    return HttpRequest.request(_service.modifyMcs, params: p);
  }

  ///获取省市县列表
  Future? getPcaList() {
    return Dio().request(HttpConfig.baseUrl + "web/json/" + _service.pcaCode,
        data: "get");
  }

  //获取我看过的和看过我的数量
  Future? getSeenNumber(String id) {
    return HttpRequest.request(_service.LookNum, params: {
      "id": id,
    });
  }

  //我看过的列表
  Future? getMeLook(String id) {
    return HttpRequest.request(_service.MeLookList, params: {
      "id": id,
    });
  }

//看过我的列表
  Future? getReadMe(String id) {
    return HttpRequest.request(_service.ReadMeList, params: {
      "id": id,
    });
  }

  /// 获取粉丝列表
  Future? getFansList(String nickName, int pageNum, int pageSize) {
    return HttpRequest.request(_service.fansList, params: {
      "nickName": nickName,
      "pageNum": pageNum,
      "pageSize": pageSize
    });
  }

  /// 获取粉丝总数
  Future? getFansTotal() {
    return HttpRequest.request(_service.fansTotal);
  }

  /// 邀请好友
  Future? invite(String curUserId, String inviteCode) async {
    String apiUrl = _service.invite;
    Map<String, dynamic> dataMap = {};
    if (inviteCode.contains('-Q')) {
      apiUrl = 'match-maker/business/inviteJoin';
      dataMap = {
        "memberId": Provider.memberId,
        "shareCode": inviteCode,
      };
    } else {
      dataMap = {"id": curUserId, "shareCode": inviteCode};
    }
    final res = await HttpRequest.request(apiUrl, params: dataMap);
    if (res != null && res['code'] == 0) {
      await Provider.remove("invite_code");
    }
    return res;
  }

  /// 上传圈子图片
  uploadMomentFromHtml(html.FormData data, Function callback) {
    final res = html.HttpRequest();
    res.open("POST",
        "${HttpConfig.baseUrl}${HttpConfig.webApi}/${_service.uploadMomentPhoto}");
    res.setRequestHeader("Authorization", HttpConfig.token);
    res.send(data);
    res.onLoadEnd.listen((event) {
      callback(jsonDecode(res.response));
    });
  }

  Future? uploadMomentPic(String path) {
    return HttpRequest.uploadFile(_service.uploadMomentPhoto,
        params: {"photos": MultipartFile.fromFileSync(path)});
  }

  /// 盲盒 - 剩余次数
  Future? blindChance() {
    return HttpRequest.request(_service.blindChance);
  }

  /// 盲盒 - 列表惊喜
  Future? blindList() {
    return HttpRequest.request(_service.blindList);
  }

  /// 盲盒 - 列表回忆
  Future? recallList(String id) {
    return HttpRequest.request(_service.recallList, params: {"id": id});
  }

  /// 盲盒 - 拆盲盒
  Future? blindOpen(String id) {
    return HttpRequest.request(_service.blindOpen, params: {"id": id});
  }

  /// 商品list
  Future? proList() {
    return HttpRequest.request(_service.proList);
  }

  /// 余额支付
  Future? payoutByBalance(String proId) {
    return HttpRequest.request(_service.payoutByBalance,
        params: {"goodsId": proId});
  }

  /// 获取用户圈子列表
  Future? getUserMood(String memberId, int pageNum, int pageSize) {
    return HttpRequest.request(_service.mood,
        params: {"pageNum": pageNum, "pageSize": pageSize});
  }

  /// 微信支付购买机会
  Future? payoutByWechat(String proId, String openId) {
    return HttpRequest.request(_service.payoutByWechat,
        params: {"goodsId": proId, "openId": openId});
  }

  /// 支付宝支付购买机会
  Future? payoutBylipay(String proId) {
    return HttpRequest.request(_service.payoutByAlipay,
        params: {"goodsId": proId});
  }

  /// 红娘类型
  Future? makerType(String memberId) {
    return HttpRequest.request(_service.makerType, params: {
      "memberId": memberId,
    });
  }

  /// 是否已实名
  Future? checkFansNumber() {
    return HttpRequest.request(_service.checkFansNumber);
  }

  /// 商家红娘-- 普通红娘--查询是否上传营业执照
  Future? checkAgency() {
    return HttpRequest.request(_service.checkAgency);
  }

  /// 商家红娘--申请普通红娘
  Future? applyBusinessMatch(String memberId) {
    return HttpRequest.request(_service.applyBusinessMatch, params: {
      "memberId": memberId,
    });
  }

  /// 商家红娘--保存行业
  Future? uploadTrade(String trade) {
    return HttpRequest.request(_service.uploadTrade, params: {
      "trade": trade,
    });
  }

  /// 申请爱心红娘
  Future? applyLoveMaker(int fansNumber, int level, int matchType) {
    return HttpRequest.request(_service.applyLoveMaker, params: {
      "fansNumber": fansNumber,
      "level": level,
      "matchType": matchType
    });
  }

  /// 申请红娘--微信
  Future? payoutByApplyMaker(String proId, int type) {
    return HttpRequest.request(_service.applyMakerByWechat,
        params: {"goodsId": proId, "matchType": type});
  }

  /// 申请红娘--支付宝
  Future? applyMakerByWechat(String proId, int type) {
    return HttpRequest.request(_service.applyMakerByAli,
        params: {"goodsId": proId, "matchType": type});
  }

  /// 升级红娘--微信
  Future? upgardeMakerByWechat(String proId, int matchType) {
    return HttpRequest.request(_service.upgardeMakerByWechat,
        params: {"goodsId": proId, "matchType": matchType});
  }

  /// 升级红娘--支付宝
  Future? urgradeMakerByAli(String proId, int matchType) {
    return HttpRequest.request(_service.urgradeMakerByAli,
        params: {"goodsId": proId, "matchType": matchType});
  }

  /// 红娘管理
  Future? makerManager(int type) {
    return HttpRequest.request(_service.makerManager, params: {
      "matchType": type,
    });
  }

  /// 绑定微信
  Future? bindWechat(String code, String memberId) {
    return HttpRequest.request(_service.bindWechat,
        params: {"code": code, "memberId": memberId});
  }

  /// 首页是否展示红娘
  Future? makerDisplay(int teg) {
    return HttpRequest.request(_service.makerDisplay, params: {
      "teg": teg,
    });
  }

  /// 微信登录 完善信息
  Future? completeInfoByWxLogin(
      String phoneNo,
      String verifyCode,
      String smsSig,
      int realSex,
      String birthYear,
      String pass,
      String comPass) {
    return HttpRequest.request(_service.completeInfoByWxLogin, params: {
      "phoneNo": phoneNo,
      "smsCode": verifyCode,
      "smsSig": smsSig,
      "realSex": realSex,
      "birthYear": birthYear,
      'password': pass,
      'comPassword': comPass,
    });
  }

  /// app登录 完善信息
  Future? completeInfoByAppLogin(String memberId, String nickName, int realSex,
      String birthYear, String profilePhoto, String sig) {
    return HttpRequest.request(_service.completeInfoByAppLogin, params: {
      "memberId": memberId,
      "nickName": nickName,
      "realSex": realSex,
      "birthYear": birthYear,
      'profilePhoto': profilePhoto,
      'sig': sig,
    });
  }

  /// 我的收益明细
  Future? walletIncomeList(int pageNum, int pageSize) {
    return HttpRequest.request(_service.incomeList,
        params: {"pageNum": pageNum, "pageSize": pageSize});
  }

  /// 获取用户圈子列表
  Future? totalIncome(String memberId) {
    return HttpRequest.request(_service.sumIncome, params: {
      "memberId": memberId,
    });
  }

  /// 总积分
  Future? totalIntergalInfo() {
    return HttpRequest.request(_service.sumIntergalInfo);
  }

  ///积分明细
  Future? IntergalList(int pageNum, int pageSize) {
    return HttpRequest.request(_service.intergalList,
        params: {"pageNum": pageNum, "pageSize": pageSize});
  }

  ///意见反馈
  Future? MeFeedBack(String opinions, String mobilePhone) {
    return HttpRequest.request(_service.meFeedBack, params: {
      "opinions": opinions,
      "mobilePhone": mobilePhone,
    });
  }

  /// 账号与安全
  Future? accountSecure() {
    return HttpRequest.request(_service.accountSecure);
  }

  /// 账号与安全
  Future? memberLogout(String memberId) {
    return HttpRequest.request(_service.memberLogout, params: {
      'memberId': memberId,
    });
  }

  /// 恢复单身商品
  Future? memberstateList() {
    return HttpRequest.request(_service.stateList);
  }

  /// 单身转非单身直接修改，非单身转单身是：先购买支付成功后返单身
  Future? weixinPay(String ID) {
    return HttpRequest.request(_service.weixinBuy, params: {
      "id": ID,
    });
  }

  Future? zhifubaoPay(String ID) {
    return HttpRequest.request(_service.zhifubaoBuy, params: {
      "id": ID,
    });
  }

  ///隐藏支付
  Future? isHiddenPay() {
    return HttpRequest.request(_service.isHiddenPay);
  }

  /// 获取用户信息
  Future? getDeletePhoto(String photoImg) {
    return HttpRequest.request(_service.getDeletePho, params: {
      "photoImg": photoImg,
    });
  }

  /// 获取员工列表
  /// matchmakerId： 商家id
  /// employeeName": 员工姓名
  Future<MemberListEntity> getMemberList({String? matchmakerId}) async{
    var response = await HttpRequest.request('match-maker/employee/queryEmployees', params: {
      "matchmakerId": matchmakerId,
    });
    return MemberListEntity.fromJson(response);
  }

  /// 添加员工
  /// matchmakerId： 商家id
  /// employeeName": 员工姓名
  Future<bool> addMember({required String matchmakerId, required String name}) async{
    var response = await HttpRequest.request('match-maker/employee/add', params: {
      "matchmakerId": matchmakerId,
      "employeeName": name,
    });
    if(response['code'] == 0){
      return true;
    }
    EasyLoading.showToast(response['msg']);
    return false;
  }
}
